using System.IO;
using System.Windows.Forms;

namespace TelliTwitter
{
    public partial class HelpForm : Form
    {
        public HelpForm()
        {
            InitializeComponent();
        }

        private void HelpForm_Load(object sender, System.EventArgs e)
        {
            webBrowser1.DocumentText = GetHelpString();
        }

        private string GetHelpString()
        {
            string templateHtml = GetResourceString("TelliTwitter.html.Help.html");

            // Parse ${css}
            string css = GetResourceString("TelliTwitter.html.tellitwitter.css");

            return templateHtml.Replace("${css}", "<style type=\"text/css\" media=\"all\">" + css + "</style>");
        }

        private string GetResourceString(string templateHtml)
        {
            using (StreamReader reader = new StreamReader(GetType().Assembly.GetManifestResourceStream(templateHtml)))
                templateHtml = reader.ReadToEnd();
            return templateHtml;
        }
    }
}